<div class="companies index">
<h2><?php __('Companies');?></h2>
<!-- Table Navigation -->
<div class="tablenav">
    <div class="batchactions"></div>
    <?php echo $this->element('pager'); ?>
</div>
<!-- Table Content Area -->
<table id="table_companies" class="table fixed">
    <thead title="<?php __('Click a column to sort data table'); ?>">
        <tr>
            <th width="5%" class="checkbox" title="<?php __('Click to select/deselect all records'); ?>"><input type="checkbox" class="checkbox" /></th>
            <th width="8%"><?php echo $paginator->sort('id');?></th>
            <th width="25%"><?php echo $paginator->sort('name');?></th>
            <th width="8%"><?php echo $paginator->sort('company_location_id');?></th>
            <th width="17%"><?php echo $paginator->sort('company_industry_id');?></th>
            <th width="10%"><?php echo $paginator->sort('company_type_id');?></th>
            <th width="8%"><?php echo $paginator->sort('clicks');?></th>
            <th width="8%"><?php echo $paginator->sort('job_count');?></th>
            <th width="16%" class="actions"><?php __('Actions');?></th>
        </tr>
    <thead>
    <tfoot title="<?php __('Click a column to sort data table'); ?>">
        <tr>
            <th class="checkbox" title="<?php __('Click to select/deselect all records'); ?>"><input type="checkbox" class="checkbox" /></th>
            <th><?php echo $paginator->sort('id');?></th>
            <th><?php echo $paginator->sort('name');?></th>
            <th><?php echo $paginator->sort('company_location_id');?></th>
            <th><?php echo $paginator->sort('company_industry_id');?></th>
            <th><?php echo $paginator->sort('company_type_id');?></th>
            <th><?php echo $paginator->sort('clicks');?></th>
            <th><?php echo $paginator->sort('job_count');?></th>
            <th class="actions"><?php __('Actions');?></th>
        </tr>
    </tfoot>
    <tbody>
        <?php foreach ($companies as $i=>$company):
            $class = $i++ % 2 == 0 ? ' class="altrow"' : ''; ?>
        <tr<?php echo $class;?>>
            <td class="checkbox"><input type="checkbox" class="checkbox" /></td>
            <td><?php echo $company['Company']['id']; ?></td>
            <td><a href="<?php echo $company['Company']['website']; ?>" title="<?php echo $company['Company']['name']; ?>"><?php echo $company['Company']['name']; ?></a></td>
            <td><?php echo $html->link(
                            $company['CompanyLocation']['name'],
                            array(
                                'controller' => 'company_locations',
                                'action' => 'view',
                                $company['CompanyLocation']['id']
                            )); ?>
            </td>
            <td><?php echo $html->link(
                        $company['CompanyIndustry']['name'],
                        array(
                            'controller' => 'company_industries',
                            'action' => 'view',
                            $company['CompanyIndustry']['id']
                        )); ?>
            </td>
            <td><?php echo $html->link(
                        $company['CompanyType']['name'],
                        array(
                        'controller' => 'company_types',
                        'action' => 'view',
                        $company['CompanyType']['id']
                        )); ?>
            </td>
            <td><?php echo $company['Company']['clicks']; ?></td>
            <td>
                <span><?php echo $company['Company']['job_count']; ?></span>
                <?php if($company['Company']['job_count']>0): ?>
                <?php echo $html->link(
                    __('(detail)', true),
                    array(
                        'controller'=>'jobs',
                        'action'=>'viewByCompany',
                        $company['Company']['id']
                    ),
                    array('title'=>__('Click to view jobs for this company', true)));?>
                <?php endif; ?>
            </td>
            <td class="actions">
                <?php echo $html->link(__('View', true), array('action' => 'view', $company['Company']['id'])); ?>
                <?php if($user['group'] != 'student'): ?>
                    <?php e($html->link(__('Edit', true), array('action' => 'edit', $company['Company']['id']))); ?>
                    <?php e($html->link(__('Delete', true), array('action' => 'delete', $company['Company']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $company['Company']['id']))); ?>
                    <!-- Script for ajax Company deletion -->
                    <script type="text/javascript">
                        jQuery(function(){
                            $('table#table_companies td.actions a[href*=delete]').click($.sme.cbk.ajaxDelete);
                        });
                    </script>
                <?php endif; ?>
            </td>
        </tr>
        <?php endforeach; ?>
    <tbody>
</table>
</div>
<div class="actions">
    <ul>
        <?php if($user['group'] != 'student'): ?>
            <li><?php echo $html->link(__('New Company', true), array('action' => 'add')); ?></li>
            <li><?php echo $html->link(__('New Company Location', true), array('controller' => 'company_locations', 'action' => 'add')); ?> </li>
            <li><?php echo $html->link(__('New Company Industry', true), array('controller' => 'company_industries', 'action' => 'add')); ?> </li>
            <li><?php echo $html->link(__('New Company Type', true), array('controller' => 'company_types', 'action' => 'add')); ?> </li>
            <li><?php echo $html->link(__('New Job', true), array('controller' => 'jobs', 'action' => 'add')); ?> </li>
            <li><?php echo $html->link(__('List Company Locations', true), array('controller' => 'company_locations', 'action' => 'index')); ?> </li>
            <li><?php echo $html->link(__('List Company Industries', true), array('controller' => 'company_industries', 'action' => 'index')); ?> </li>
            <li><?php echo $html->link(__('List Company Types', true), array('controller' => 'company_types', 'action' => 'index')); ?> </li>
        <?php endif; ?>
        <li><?php echo $html->link(__('List Jobs', true), array('controller' => 'jobs', 'action' => 'index')); ?> </li>
    </ul>
</div>